package LeetCode;

/**
 * @Author Kechelle
 * @Date 2020/9/10 20:53
 * @Version 1.0
 */
public class Code26 {
    public static int removeDuplicates(int[] nums) {
        int i=0;   //定义一个慢指针；
        for (int j=1;j< nums.length;j++){
            if (nums[j]!=nums[i]){
                i++;
                nums[i]=nums[j];
            }
        }
        return i+1;
    }

    public static void main(String[] args) {
        int[] nums = {1,1,2};
        System.out.println(Code26.removeDuplicates(nums));
    }
}
